package com.kernel.streamDemo;

import java.io.*;

/****************************************
 * @name OutputStreamWriterDemo
 * @description 字节字符转换流学习
 * @author 黄彬恒
 * @since 2018/8/17
 ***************************************/
public class OutputStreamWriterDemo01 {
    public static void main(String[] args) {
        File file = new File("D:\\ideaProgram\\IOLearning\\src\\main\\resources\\4.txt");
        Writer writer = null;
        try {
            writer = new OutputStreamWriter(new FileOutputStream(file, true));// 包装字节流操作,把字节流转换成为字符流(装饰者设计模式)
            writer.write("\r\nhello world!");// 使用字符流输出
            writer.close();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
